package cn.iocoder.yudao.module.etl.controller.admin.engine;


import cn.iocoder.yudao.module.etl.dal.dataobject.DeEngine;
import cn.iocoder.yudao.module.etl.dto.DatasourceDTO;
import cn.iocoder.yudao.module.etl.service.engine.EngineService;
import cn.iocoder.yudao.module.etl.utils.ResultHolder;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import javax.annotation.Resource;

@ApiIgnore
@RequestMapping("etl/engine")
@RestController
public class EngineController {

    @Resource
    private EngineService engineService;

    @ApiIgnore
    @GetMapping("/mode")
    public String  runMode() throws Exception{
        return engineService.mode();
    }

    @ApiOperation("引擎信息")
    @GetMapping("/info")
    public DeEngine info() throws Exception{
        return engineService.info();
    }

    @ApiIgnore
    @PostMapping("/validate")
    public ResultHolder validate(@RequestBody DatasourceDTO datasource) throws Exception {
        return engineService.validate(datasource);
    }


    @ApiOperation("新增/编辑")
    @PostMapping("/save")
    public ResultHolder save(@RequestBody DeEngine engine) throws Exception {
        return engineService.save(engine);
    }
}
